package com.tangl.demo.confirmation;

import com.alibaba.fastjson.JSON;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author: TangLiang
 * @date: 2020/8/6 16:54
 * @since: 1.0
 */
@Component
public class SendEmailMessage implements CheckMessageHandler {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Override
    public void send(Map map) {
        rabbitTemplate.convertAndSend("sendEmail", JSON.toJSONString(map));
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        CheckMessageFactory.register("sendEmail", this);
    }
}
